﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Inicio.Entities;
using System.Data.SqlServerCe;

namespace Inicio.Core.Repositories
{
    public class CountryRepositorie
    {
        public List<Country> LoadCountrys(string conec)
        {
            List<Country> countrys = new List<Country>();
            using (SqlCeConnection cn = new SqlCeConnection(conec))
            {
                cn.Open();
                using (SqlCeCommand cmd = new SqlCeCommand("select * from Country ORDER BY countryName ASC", cn))
                {
                    using (SqlCeDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            countrys.Add(new Country((int)reader["id"], reader["countryName"].ToString()));
                        }
                    }
                }
            }
            return countrys;
        }
    }
}
